import axios from 'axios';
import path from './path';

// 创建实例
const instance = axios.create({
    baseURL: path.baseURL,
    timeout: 5 * 60 * 1000,
});

// 添加请求拦截器
instance.interceptors.request.use(function (config) {
  console.log("【请求报文==>】：", config.url, config, sessionStorage.getItem("TOKEN"))
    // 设置token
    config.headers.setAuthorization(sessionStorage.getItem("TOKEN"));
    return config;
  }, function (error) {
    return Promise.reject(error);
  });

// 添加响应拦截器
instance.interceptors.response.use(function (response) {
  console.log("【响应报文==>】：", response.request.responseURL, response)
    return response;
  }, function (error) {
    return Promise.reject(error);
});


export default instance;